package com.inifitness.tenant.core.config.mp.handler;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * Mybatis-Plus租户上下文
 *
 * @author sunjinfeng
 * @version 1.0.0
 * @since 2024-05-09 10:45
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MybatisTenantContext {

  private static final ThreadLocal<Boolean> TENANT_CONTEXT_THREAD_LOCAL = new ThreadLocal<>();

  public static Boolean get() {
    return TENANT_CONTEXT_THREAD_LOCAL.get();
  }

  public static void set(boolean isIgnore) {
    TENANT_CONTEXT_THREAD_LOCAL.set(isIgnore);
  }

  public static void clear() {
    TENANT_CONTEXT_THREAD_LOCAL.remove();
  }
}
